<template>
	<view>
		<!-- 不能加.vue后缀 -->
		<navigator url="/pages/index/index" open-type="navigate"><button type="primary">index页面</button></navigator>
		<navigator url="../style/style" open-type="redirect"><button type="primary">style页面</button></navigator>
		<navigator url="../form_uni/form_uni" open-type="redirect"><button type="primary">表单页面</button></navigator>

		<button type="default" @click="handleClick">api跳转页面</button>
		<navigator url="../setup/setup"><button>setup页面</button></navigator>
		<navigator url="../http/http"><button>http</button></navigator>
		<navigator url="../pinia_use/pinia_use"><button>ppinia</button></navigator>
	</view>
</template>

<script>
export default {
	data() {
		return {};
	},
	onShow() {
		console.log('page show');
	},
	onLoad() {
		uni.$on('backEvents', data => {
			console.log('返回的数据是', data);
		});
	},
	methods: {
		handleClick: function() {
			uni.navigateTo({
				url: '/pages/index/index?id=1&name=uniapp',
				success(res) {
					res.eventChannel.emit('acceptData', {
						data: '从其他页面的数据'
					});
				},
				//跳转回来的页面数据eventChannel在这里监听
				events: {
					back({ data }) {
						console.log('backData', data);
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
button {
	margin: 15rpx;
}
</style>
